package com.azydbly.controller;

import com.azydbly.datasource.SlaveOne;
import com.azydbly.datasource.SlaveThree;
import com.azydbly.datasource.SlaveTwo;
import com.azydbly.service.IYxUserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 *  自定义注解
 * </p>
 *
 * @author yixi
 * @since 2022-08-19
 */
@RestController
@RequestMapping("/custom/user")
public class CustomUserController {

    @Resource
    private IYxUserService yxUserService;


    /**
     * 获取所有用户(从库1)
     *
     * @return
     */
    @GetMapping("slave1")
    @SlaveOne
    public List getAllUserForSlaveOne() {
        return yxUserService.list();
    }

    /**
     * 获取所有用户(从库2)
     *
     * @return
     */
    @GetMapping("slave2")
    @SlaveTwo
    public List getAllUserForSlaveTwo() {
        return yxUserService.list();
    }

    /**
     * 获取所有用户(从库3)
     *
     * @return
     */
    @GetMapping("slave3")
    @SlaveThree
    public List getAllUserForSlaveThree() {
        return yxUserService.list();
    }
}
